namespace GadgetStore.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class ChangeDatabase : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Gadgets",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Descript = c.String(),
                        TopPict = c.String(),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                        Qty = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Pictures",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PictUrl = c.String(),
                        GadgetId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Gadgets", t => t.GadgetId, cascadeDelete: false)
                .Index(t => t.GadgetId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Pictures", "GadgetId", "dbo.Gadgets");
            DropIndex("dbo.Pictures", new[] { "GadgetId" });
            DropTable("dbo.Pictures");
            DropTable("dbo.Gadgets");
        }
    }
}
